<?php
/**
 * User: day
 * Date: 2018/08/12
 * Time: 17:35
 */

namespace App\Services;



use App\Models\Order;

class OrderService {
    /**
     * 
     */
    public static function getValidBet($userID, $beginTime, $endTime)
    {
        $sql = "
            SELECT SUM(total)
            FROM(
            SELECT SUM(valid_bet) as total from `[order]` where user_id={$userID} and created BETWEEN '{$beginTime}' and '{$endTime}'
            UNION ALL 
            SELECT SUM(valid_money) as total from `[order_3th]` where user_id={$userID} and created BETWEEN '{$beginTime}' and '{$endTime}')
        ";
        return DB::select($sql);
    }
}